home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Commands / Commander.h < prev    next >
Text File  |  1997-06-28  |  940b  |  43 lines

  1. // Commander.h
  2.  
  3. #ifndef Commander_h
  4. #define Commander_h
  5.  
  6. #ifndef Assert_h
  7. #include "Assert.h"
  8. #endif
  9. #ifndef ContextMaintainer_h
  10. #include "ContextMaintainer.h"
  11. #endif
  12. #ifndef CommandLink_h
  13. #include "CommandLink.h"
  14. #endif
  15.  
  16. template < class Protocol >
  17. class Commander
  18.   {
  19.     typedef CommandLink< Protocol > LinkType;
  20.     
  21.     private:
  22.         ContextMaintainer oldContext;
  23.         
  24.     public:
  25.         Commander()
  26.           : oldContext( *LinkType::ActiveHandler() )
  27.           {
  28.             Assert( LinkType::ActiveHandler() != 0 );
  29.           }
  30.         
  31.         Protocol& operator*()                    { Assert( !Null() ); return *LinkType::ActiveHandler(); }
  32.  
  33.         Protocol *operator->()                    { Assert( !Null() ); return LinkType::ActiveHandler(); }
  34.         
  35.         const Protocol& operator*() const    { Assert( !Null() ); return *LinkType::ActiveHandler(); }
  36.         
  37.         const Protocol *operator->() const    { Assert( !Null() ); return LinkType::ActiveHandler(); }
  38.  
  39.         static bool Null()                        { return LinkType::ActiveHandler() == 0; }
  40.   };
  41.  
  42. #endif
  43.